#include <bits/stdc++.h>
#define int long long
using namespace std;
int T,n,m,l,v,p[100005],tot,lst,ans;
struct node
{
    int d,v,a;
}c[100005];
struct ned
{
    int l,r;
}a[100005];
bool cmp(ned x,ned y)
{
    if(x.r==y.r) return x.l<y.l;
    return x.r<y.r;
}
void solve()
{
    tot=ans=lst=0;
    scanf("%lld%lld%lld%lld",&n,&m,&l,&v);
    for(int i=1;i<=n;i++) scanf("%lld%lld%lld",&c[i].d,&c[i].v,&c[i].a);
    for(int i=1;i<=m;i++) scanf("%lld",p+i);
    sort(p+1,p+1+m);
    for(int i=1;i<=n;i++)
    {
        if(c[i].a==0)
        {
            if(c[i].v<=v) continue;
            int pl=lower_bound(p+1,p+1+m,c[i].d)-p;
            if(pl>m) continue;
            a[++tot].l=pl;
            a[tot].r=m;
        }
        else if(c[i].a<0)
        {
            int pl=lower_bound(p+1,p+1+m,c[i].d)-p;
            long double t=(long double)1.0*(v-c[i].v)/c[i].a;
            int pr=upper_bound(p+1,p+1+m,c[i].d+t*c[i].v+0.5*c[i].a*t*t-(1e-6))-p-1;
//            long double x=0,y=1e6,mid;
//            for(int j=1;j<=100;j++)
//            {
//                mid=(x+y)/2;
////                cerr<<mid<<' '<<c[i].v*c[i].v+2*mid*c[i].a<<endl;
//                if(c[i].v*c[i].v+2*mid*c[i].a<0) y=mid;
//                else if(c[i].v*c[i].v+2*mid*c[i].a>v*v) x=mid;
//                else y=mid;
//            }
//            int pr=upper_bound(p+1,p+1+m,c[i].d+x)-p-1;
            if(pr>m) pr--;
            if(pl>pr) continue;
            a[++tot].l=pl;
            a[tot].r=pr;
//            cerr<<i<<' '<<x<<' '<<y<<endl;
        }
        else
        {
            long double t=(long double)1.0*(v-c[i].v)/c[i].a;
            int pl=lower_bound(p+1,p+1+m,c[i].d+t*c[i].v+0.5*c[i].a*t*t-(1e-6))-p;
//            long double x=0,y=1e6,mid;
//            for(int j=1;j<=100;j++)
//            {
//                mid=(x+y)/2;
////                cerr<<mid<<' '<<c[i].v*c[i].v+2*mid*c[i].a<<endl;
//                if(c[i].v*c[i].v+2*mid*c[i].a<0) x=mid;
//                else if(c[i].v*c[i].v+2*mid*c[i].a>v*v) y=mid;
//                else x=mid;
//            }
//            int pl=upper_bound(p+1,p+1+m,c[i].d+y)-p;
            if(pl>m) continue;
            a[++tot].l=pl;
            a[tot].r=m;
        }
    }
    sort(a+1,a+1+tot,cmp);
    for(int i=1;i<=tot;i++) if(a[i].l>lst) lst=a[i].r,ans++;
    printf("%lld %lld\n",tot,m-ans);
    return ;
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);
    while(T--) solve();
}
